#!/usr/bin/env bash
# usage: ./bootstrap.sh COMMAND [LOGFILEPATH]
log_file_path="log"
if [[ $2 != "" ]]; then
    log_file_path=$2
fi
log_file=$log_file_path"/"`date +%Y%m%d`"_log.txt"

check_file(){
 echo "check file"
 echo $log_file

 if [ -e $log_file_path ]; then
     if [ -e $log_file ]; then
        echo "logfile is ready"
        else
        echo "logfile is ready"
        touch $log_file
     fi
    else
    mkdir $log_file_path
    touch $log_file
    echo "logfile is ready"
 fi
}
start(){
 check_file
 echo "started";
}
stop(){
 echo "stop";
}
restart(){
 echp "restarting";
 start
 restart
}
usage(){
  echo ""
  echo "usage: ./bootstrap.sh COMMAND"
  echo ""
  echo "Commands:[start/stop/restart]"
  echo ""
}

cmd_start="start"
cmd_stop="stop"
cmd_restart="restart"



if  [ $1 = $cmd_start ];then
    start
    elif  [ $1 = $cmd_stop ]; then
        stop
        elif [ $1 = $cmd_restart ]; then
        restart
        else
        usage
fi

